package org.example.Server.controller.examination;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.examination.ExamStu;
import org.example.Server.model.examination.ExamStuDTO;
import org.example.Server.model.examination.ExamSubmitDTO;
import org.example.Server.service.examination.StuExamService;
import org.example.Server.service.examination.TeachExamService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/youxich/exam/stu")
public class ExamStuController {
    @Autowired
    StuExamService stuExamService;

    /**
     * 获取学生端考试列表
     *
     * @param sem_id
     * @param status
     * @param user_id
     * @return
     */
    @GetMapping
    public ResultAPI getExamStuList(@RequestParam Integer sem_id, @RequestParam(required = false) Integer status, @RequestParam Integer user_id) {
        return stuExamService.getStuExamList(sem_id, status, user_id);
    }

    /**
     * 获取学生答题详情：模块得分，每一题得分等
     *
     * @param examStu
     * @return
     */
    @PostMapping("/detail")
    public ResultAPI getExamDetail(@RequestBody ExamStuDTO examStu) {
        ResultAPI result = null;
        result = stuExamService.getExamStuDetail(examStu);
        return result;
    }

    /**
     * 学生提交考试
     *
     * @param examSubmitDTO
     * @return
     */
    @PostMapping
    public ResultAPI stuSubmit(@RequestBody ExamSubmitDTO examSubmitDTO) {
        return stuExamService.stuSubmit(examSubmitDTO);
    }
}
